home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15619 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  64 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.ifm.liu.se!liuida!t94danfr
  3. From: t94danfr@ida.liu.se (Yankee Doodle Floppy Disk)
  4. Subject: Re: Q: '\n' character
  5. X-Nntp-Posting-Host: su2-8.ida.liu.se
  6. Message-ID: <t94danfr.829996402@news>
  7. Sender: news@ida.liu.se
  8. Organization: CIS Dept, Linkoping University, Sweden
  9. X-Newsreader: NN version 6.5.0 #6 (NOV)
  10. References: <4kj66f$k0o@ren.cei.net> <1996Apr11.192937.25676@sq.com> <829396473snz@genesis.demon.co.uk> <4kpd2g$eeb@masala.cc.uh.edu> <317109ea.316698628@nntp.ix.netcom.com> <4kt1f2$jjk@sparcserver.lrz-muenchen.de>
  11. Date: Sat, 20 Apr 1996 10:33:22 GMT
  12.  
  13. ua302aa@lrz-muenchen.de () writes:
  14.  
  15. >miker3@ix.netcom.com (Mike Rubenstein) writes:
  16. >>> Ok, I've got a question at this point.  Is it really proper to say
  17. >>> if (ptr)? 
  18.  
  19. >Yes, it's "proper".
  20.  
  21. >>Read some different books.
  22.  
  23. >>    if (ptr)
  24. >>      statement1
  25.  
  26. >>executes statement1 if ptr compares equal to 0 (ISO 6.6.4), i.e., if
  27. >>ptr == 0.
  28.  
  29. >I'd say "if (ptr)" is aequivalent to "if ((ptr) != 0)", and "statement1"
  30. >will be executed if "ptr" does not compare equal to 0
  31.  
  32. >Kurt
  33. >-- 
  34. >| Kurt Watzka                             Phone : +49-89-2180-6254
  35. >| watzka@stat.uni-muenchen.de
  36.  
  37. Just a tip:
  38.  
  39. According to Elemtel's styleguide for C/C++ you should really compare
  40. variables and pointers with something, instead of just typing:
  41.  
  42. if (ptr)
  43.   statement;
  44.  
  45. you should type:
  46.  
  47. if (ptr != something)
  48.   statement;
  49.  
  50. or:
  51.  
  52. if (ptr == something_else)
  53.     statement;
  54.  
  55. This way of writing code prevents the code from being bugprone in some extent.
  56. Especially while writing large programs.
  57.  
  58.  
  59. --
  60.  
  61.          ......
  62.       .+(MMMMMMHn.
  63.     :*`xMMMMMMMMMMh. 
  64.